<?php

namespace app\user\controller;

use think\Controller;
use Endroid\QrCode\QrCode;
use think\Response;

class Qrcodes extends Controller
{
    const LOGOURL = '11.png';

    public function index()
    {
    	$data = input('get.data');
        $size = input('get.size',300);
        $logo_size = $size / 2;

    	$qrCode = new QrCode();
        $qrCode->setText($data)
               ->setSize($size)
               ->setPadding(10)
               ->setErrorCorrection('high')
               ->setLogo(self::LOGOURL)
               ->setLogoSize($logo_size)
               ->setImageType(QrCode::IMAGE_TYPE_PNG);

        return new Response($qrCode->get(), 200, array('Content-Type' => $qrCode->getContentType()));
    }
}
